package com.lge.clock.worldclock;

import com.lge.clock.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.DialogInterface.OnKeyListener;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.util.Log;

public class LowOnSpaceDialog extends Activity 
{	
	private AlertDialog.Builder ad = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);

		final Window win = getWindow();
		win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
		
		Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
		sendBroadcast(closeDialogs);
		
		win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
		
		this.setContentView(R.layout.timerdialog);
		ad = new AlertDialog.Builder(this);
		ad.setIconAttribute(android.R.attr.alertDialogIcon)
		.setTitle(com.lge.clock.R.string.sp_low_internal_storage_title_NORMAL)
		.setMessage(com.lge.clock.R.string.sp_low_memory_NORMAL)
		.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() 
		{
			
			public void onClick(DialogInterface arg0, int arg1) {
				finish();
			}
		})
		/*[START] 2012.03.12 suein1209.kim OFFICIAL_EVENT.Mobile_12 - Defect #23238*/
		.setCancelable(false)
		/*[END] 2012.03.12 suein1209.kim OFFICIAL_EVENT.Mobile_12 - Defect #23238*/
		.setOnKeyListener(new OnKeyListener() {
			public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
					switch (keyCode) 
					{
						case KeyEvent.KEYCODE_BACK:
							finish();
							return true;
						default :
							return false;
					}
			}
		}).show();
		Log.i("LowOnSpaceDialog","LowOnSpaceDialog!!");
	}
}
